﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WXYW.BLL;

namespace WXYW
{
    public partial class AccordingToClientRecords : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindUsers();
            }
        }

        private void BindUsers()
        {
            UserService service = new UserService();
            userGridView.DataSource = service.GetUsersByKeyword(keyWordTextBox.Text, (int)RoleType.Customer);
            userGridView.DataBind();

        }

        protected void searchLinkButton_Click(object sender, EventArgs e)
        {
            BindUsers();
        }

        protected void resetLinkButton_Click(object sender, EventArgs e)
        {
            keyWordTextBox.Text = "";
            BindUsers();
        }

        protected void userGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            if (e.NewPageIndex >= 0 && e.NewPageIndex < userGridView.PageCount)
            {
                userGridView.PageIndex = e.NewPageIndex;
            }
            
            BindUsers();
        }

        protected void viewLinkButton_Click(object sender, EventArgs e)
        {
            string userID = ((LinkButton)sender).CommandArgument;
            Response.Redirect(string.Format("UsersApplicationForms.aspx?{0}={1}", Constants.QUERYSTR_USER_ID, userID));
        }
    }
}
